home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbdatabs / rbnode.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-03-14  |  2.8 KB  |  82 lines

  1. // ------------------------------- //
  2. // -------- Start of File -------- //
  3. // ------------------------------- //
  4. // ----------------------------------------------------------- //
  5. // C++ Header File Name: rbnode.h
  6. // Compiler Used: MSVC40, DJGPP 2.7.2.1, GCC 2.7.2.1, HP CPP 10.24
  7. // Produced By: Doug Gaer   
  8. // File Creation Date: 01/23/1997 
  9. // Date Last Modified: 03/15/1999
  10. // Copyright (c) 1997 Douglas M. Gaer
  11. // ----------------------------------------------------------- // 
  12. // ---------- Include File Description and Details  ---------- // 
  13. // ----------------------------------------------------------- // 
  14. /*
  15. The VBD C++ classes are copyright (c) 1997, by Douglas M. Gaer.
  16. All those who put this code or its derivatives in a commercial
  17. product MUST mention this copyright in their documentation for
  18. users of the products in which this code or its derivative
  19. classes are used. Otherwise, you have the freedom to redistribute
  20. verbatim copies of this source code, adapt it to your specific
  21. needs, or improve the code and release your improvements to the
  22. public provided that the modified files carry prominent notices
  23. stating that you changed the files and the date of any change.
  24.  
  25. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
  26. THE ENTIRE RISK OF THE QUALITY AND PERFORMANCE OF THIS SOFTWARE
  27. IS WITH YOU. SHOULD ANY ELEMENT OF THIS SOFTWARE PROVE DEFECTIVE,
  28. YOU WILL ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR
  29. CORRECTION.
  30.  
  31. (R)ed (B)lack (B)inary (T)ree node classes. The RBNodeBase
  32. class is derived from the BNodeBase class. The generic RBNode
  33. class is then derived from the RBNodeBase class.
  34. */
  35. // ----------------------------------------------------------- //   
  36. #ifndef __RBNODE_HPP
  37. #define __RBNODE_HPP
  38.  
  39. #include "bnodeb.h"
  40.  
  41. #define RedNode 0
  42. #define BlackNode 1
  43.  
  44. // (R)ed (B)lack (N)ode (B)ase class
  45. class RBNodeBase : public BNodeBase
  46. {
  47. public:
  48.   RBNodeBase *GetLeft() { return (RBNodeBase *)Left; }
  49.   RBNodeBase *GetRight() { return (RBNodeBase *)Right; }
  50.  
  51. public:
  52.   char color; // Color of the link coming into the node
  53. };
  54.  
  55. // (R)ed (B)lack (N)ode class
  56. template<class TYPE>
  57. class RBNode : public RBNodeBase
  58. {
  59. public:
  60.   RBNode() { Left = 0; Right = 0; color = BlackNode; }
  61.  
  62.   RBNode // RBNode copy constructor
  63.   (const TYPE &X, char c=1, RBNode<TYPE> *l=0, RBNode<TYPE> *r=0) : Data(X)
  64.   {
  65.     Left = l; Right = r; color = c;
  66.   }
  67.  
  68. public:
  69.   RBNode<TYPE> *GetLeft() { return (RBNode<TYPE> *)Left; }
  70.   RBNode<TYPE> *GetRight() { return (RBNode<TYPE> *)Right; }
  71.  
  72. public:
  73.   TYPE Data;
  74. };
  75.  
  76. #endif // __RBNODE_HPP
  77. // ----------------------------------------------------------- // 
  78. // ------------------------------- //
  79. // --------- End of File --------- //
  80. // ------------------------------- //
  81.  
  82.